#!/usr/bin/env python

import os, sys
import mad
import glob, math

def executecmd(cmdstring):
	print cmdstring
	os.system(cmdstring)
	
 
if (len(sys.argv) > 1):
	path = sys.argv[1]
else:
	path = '.'

for infile in glob.glob( os.path.join(path, '*.MP4') ):	

	# set filename
	workingfileprefix = infile.rstrip('.MP4').lstrip('./')
	print(workingfileprefix)

	#trimvid
	executecmd(('/home/emlyn/dev/vidworking/convertmp4tompeg.py %s.MP4 %sraw.mpg') % (workingfileprefix, workingfileprefix))
		
print "Done."


